﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Data;
using System.Windows;

namespace Infrastructure.WpfClient.Converts
{
    public class VisibilityBooleanConverter : IValueConverter
    {
        private static VisibilityBooleanConverter _instance;
        public static VisibilityBooleanConverter Instance {
            get {
                if (_instance == null) _instance = new VisibilityBooleanConverter();
                return _instance;
            }
        }
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            if (value == null) return Visibility.Collapsed;
            if (value is bool)
            {
                if ((Boolean)value) return Visibility.Visible;
                else return Visibility.Collapsed;
            }
            else
                return Visibility.Collapsed; 
        }
        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
